|
class ComponentDefinition |
|
Parent: DrawingElement |
|
|
Methods: <=>, ==, behavior, count_instances, description, description=, entities, group?, guid, hidden?, image?, insertion_point, instances, internal?, name, name=, path, save_thumbnail |
|
|
Sample Code:cdtests.rb |
|
|
Instance Methods |
|
<=> |
|
The <=> method is used to compare two ComponentDefinition objects for sorting. The comparison is done based on the component name. |
|
Syntax: |
|
status = componentdefinition1 <=> componentdefinition2 |
|
Arguments: |
|
componet1 - the first component in the comparison component2 - the second component in the comparison |
|
Return Value: |
|
status - a -1 if component1 is less then component2. A 1 if component1 greater than component2 |
|
Comments: |
|
|
|
Example: |
|
path1=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" definitions = model.definitions # Yields a -1 |
|
== |
|
The == method is used to test if two ComponentDefinition objects are the same (based on their address in memory). |
|
Syntax: |
|
status = componentdefinition1 == componentdefinition2 |
|
Arguments: |
|
componetdefinition1 - the first component definition in the comparison componentdefinition2 - the second component definition in the comparison |
|
Return Value: |
|
status - true if the ComponentDefinition objects are the same object. False if the objects are not the same. |
|
Comments: |
|
|
|
Example: |
|
path1=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" model = Sketchup.active_model # Yields a false |
|
behavior |
|
The behavior method is used to retrieve the Behavior object associated with a component definition. |
|
Syntax: |
|
behavior = componentdefinition.behavior |
|
Arguments: |
|
|
|
Return Value: |
|
behavior - a Behavior object if successful |
|
Comments: |
|
|
|
Example: |
|
path=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" if (behavior) |
|
count_instances |
|
The count_instances method is used to count the number of component instances in a model using this component definition. |
|
Syntax: |
|
count = componentdefinition.count_instances |
|
Arguments: |
|
|
|
Return Value: |
|
count - the number of component instances of this component definition (if successful) |
|
Comments: |
|
|
|
Example: |
|
path=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" |
|
description |
|
The description method is used to retrieve the description of the component definition. |
|
Syntax: |
|
description = componentdefinition.description |
|
Arguments: |
|
|
|
Return Value: |
|
description - the description of the component definition if successful |
|
Comments: |
|
Component definitions do not have a description, by default. |
|
Example: |
|
# Set the description |
|
description= |
|
The description= method is used to set the description for the component definition. |
|
Syntax: |
|
status = componentdefinition.description = description |
|
Arguments: |
|
|
|
Return Value: |
|
status - the description if successful, false if unsuccessful |
|
Comments: |
|
|
|
Example: |
|
componentdefinition.description="This
is a traditional bed" |
|
entities |
|
The entities method retrieves a collection of all the entities in the component definition |
|
Syntax: |
|
entities=componentdefinition.entities |
|
Arguments: |
|
|
|
Return Value: |
|
entities - an Entities object if successful |
|
Comments: |
|
|
|
Example: |
|
entities = componentdefinition.entities if (entities) |
|
group? |
|
The group? method is used to determine if this component definition is used to hold the elements of a group. |
|
Syntax: |
|
status = componentdefinition.group? |
|
Arguments: |
|
|
|
Return Value: |
|
status - true if the definition is used to hold a group, false if the definition does not hold a group. |
|
Comments: |
|
|
|
Example: |
|
path=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" if (status) |
|
guid |
|
The guid method is used to retrieve the unique identifier of this component definition. |
|
Syntax: |
|
guid = componentdefinition.guid |
|
Arguments: |
|
|
|
Return Value: |
|
guid - a string guid if successful |
|
Comments: |
|
|
|
Example: |
|
guid = componentdefinition.guid |
|
hidden? |
|
The hidden method is used to determine if this component definition should be hidden on the component browser. |
|
Syntax: |
|
status = componentdefinition.hidden? |
|
Arguments: |
|
|
|
Return Value: |
|
status - true if the definition should be hidden, false if the definition should not be hidden |
|
Comments: |
|
|
|
Example: |
|
status = componentdefinition.hidden? |
|
instances |
|
The instances method is used to determine the number of component instances that use this component definition |
|
Syntax: |
|
instances = componentdefinition.instances |
|
Arguments: |
|
|
|
Return Value: |
|
instances - the number of instances based on this component definition (if successful) |
|
Comments: |
|
|
|
Example: |
|
status = componentdefinition.image? |
|
image? |
|
The image method is used to determine if this component definition is used to define an image. |
|
Syntax: |
|
status = componentdefinition.image? |
|
Arguments: |
|
|
|
Return Value: |
|
status - true if the component definition defines an image, false if the component definition does not define an image. |
|
Comments: |
|
|
|
Example: |
|
status = componentdefinition.image? |
|
insertion_point |
|
The insertion_point method is used to retrieve the Point3d object where the component was inserted. |
|
Syntax: |
|
point = componentdefinition.insertion_point |
|
Arguments: |
|
|
|
Return Value: |
|
point - the Point3d where the component was inserted if successful. False if unsuccessful. |
|
Comments: |
|
|
|
Example: |
|
point = Geom::Point3d.new 10,20,30 |
|
internal? |
|
The internal? method is used to determine if the component definition is internal to the Component Browser |
|
Syntax: |
|
status = componentdefinition.internal? |
|
Arguments: |
|
|
|
Return Value: |
|
status - true if the component definition is internal to SketchUp's Component Browser. False if the component definition is not internal to SketchUp. |
|
Comments: |
|
|
|
Example: |
|
point = Geom::Point3d.new 10,20,30 |
|
name |
|
The name method retrieves the name of the component definition. |
|
Syntax: |
|
name = componentdefinition.name |
|
Arguments: |
|
|
|
Return Value: |
|
name - the component definition's name if successful |
|
Comments: |
|
|
|
Example: |
|
path=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" |
|
name= |
|
The name= method is used to set the name of the component definition. |
|
Syntax: |
|
name - componentdefinition.name = name |
|
Arguments: |
|
|
|
Return Value: |
|
name - the name assigned to the component definition if successful |
|
Comments: |
|
|
|
Example: |
|
path=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" |
|
path |
|
The path method is used to retrieve the path where the component was loaded. |
|
Syntax: |
|
path = componentdefinition.path |
|
Arguments: |
|
|
|
Return Value: |
|
path - a valid path if successful, false if unsuccessful |
|
Comments: |
|
Returns nil if it is an internal component. |
|
Example: |
|
path=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" |
|
save_thumbnail |
|
The save_thumbnail method is used to save a thumbnail image to a file. |
|
Syntax: |
|
status = componentdefinition.save_thumbnail "filename" |
|
Arguments: |
|
"filename" - the name of the file, with extension, to save the thumbnail as |
|
Return Value: |
|
status - true if successful, false if unsuccessful |
|
Comments: |
|
Returns nil if it is an internal component. |
|
Example: |
|
path
= Sketchup.find_support_file "fan.skp" ,"Components/Architecture_Sampler/" |